﻿using University.Workshop.Business;
using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for EmployeeManagerTest and is intended
    ///to contain all EmployeeManagerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class EmployeeManagerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        
        //Use TestCleanup to run code after each test has run
        [TestCleanup()]
        public void MyTestCleanup()
        {
        }
        
        #endregion


        /// <summary>
        ///A test for RegisterEmployeeManager
        ///</summary>
        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void RegisterEmployeeManagerTest()
        {
            string ci = "sdfd"; // TODO: Initialize to an appropriate value
            string name = "andress"; // TODO: Initialize to an appropriate value
            string surname = "peredo"; // TODO: Initialize to an appropriate value
            string workArea = ""; // TODO: Initialize to an appropriate value
            string email = ""; // TODO: Initialize to an appropriate value
            string telephone = "sdf"; // TODO: Initialize to an appropriate value
            string address = ""; // TODO: Initialize to an appropriate value
            EmployeeManager.RegisterEmployeeManager(ci, name, surname, workArea, email, telephone, address);
        }
        [TestMethod()]
        public void RegisterEmployeeManagerTest2()
        {
            Random rand = new Random();
            string ci = string.Empty;
            do
            {
                ci += rand.Next(0, 9).ToString();   
            } while (ci.Length<8);
             // TODO: Initialize to an appropriate value
            string name = "andress"; // TODO: Initialize to an appropriate value
            string surname = "peredo"; // TODO: Initialize to an appropriate value
            string workArea = "cocina"; // TODO: Initialize to an appropriate value
            string email = "rom"+rand.Next(int.MaxValue)+"@hotmail.com"; // TODO: Initialize to an appropriate value
            string telephone = "548754548"; // TODO: Initialize to an appropriate value
            string address = "Av. Santivañes"; // TODO: Initialize to an appropriate value
            EmployeeManager.RegisterEmployeeManager(ci, name, surname, workArea, email, telephone, address);
            EmployeeRegister employe = new EmployeeRegister();
            Assert.IsTrue(employe.ExistEmployee(ci));
        }
    }
}
